#include<bits/stdc++.h>
using namespace std;
const long long p=106;
const long long m=25;
const long long BASE=137;
const long long MOD1=998244353;
const long long MOD2=1e9+9;
long long pw1[100010],pw2[100010],p1[26][100010],p2[26][100010];
long long n,q,l1,r1,l2,r2,sum,book[26];
char s[100010];
inline bool check(long long l1,long long r1,long long l2,long long r2,long long x)
{
	long long len=r1-l1+1;
	if(((p1[x][r1]-p1[x][l1-1]*pw1[len]%MOD1)+MOD1)%MOD1!=((p1[x][r2]-p1[x][l2-1]*pw1[len]%MOD1)+MOD1)%MOD1)
		return 0;
	if(((p2[x][r1]-p2[x][l1-1]*pw2[len]%MOD2)+MOD2)%MOD2!=((p2[x][r2]-p2[x][l2-1]*pw2[len]%MOD2)+MOD2)%MOD2)
		return 0;
	return 1;
}
int main()
{
	long long i,j;
	scanf("%lld %lld",&n,&q);
	scanf("%s",s+1);
	for(i=1;i<=n;++i)
	{
		for(j=0;j<=m;++j)
		{
			if(s[i]=='a'+j)
				p1[j][i]=(p1[j][i-1]*BASE+p)%MOD1,p2[j][i]=(p2[j][i-1]*BASE+p)%MOD2;
			else
				p1[j][i]=(p1[j][i-1]*BASE+p+1)%MOD1,p2[j][i]=(p2[j][i-1]*BASE+p)%MOD2;
		}
	}
	pw1[0]=pw2[0]=1;
	for(i=1;i<=n;++i)
		pw1[i]=pw1[i-1]*BASE%MOD1,pw2[i]=pw2[i-1]*BASE%MOD2;
	for(i=1;i<=q;++i)
	{
		scanf("%lld %lld %lld %lld",&l1,&r1,&l2,&r2);
		for(j=0;j<=m;++j)
		{
			if(!check(l1,r1,l2,r2,j))
				++sum,book[j]=1;
		}
		printf("%lld\n",sum);
		for(j=0;j<=m;++j)
		{
			if(book[j])
				printf("%c",'a'+j);
			book[j]=0;
		}
		sum=0;
		printf("\n");
	}
	return 0;
}
